<template>
  <!-- 系统首页内容 -->
  <component :is="homeComponent" />
</template>
<script>
import storage from 'store'
import { APP_USER, APP_DEPT } from '@/store/mutation-types.js'
import { ADMREVIEW_DEPART, CORRECTION_DEPART } from '@/utils/custom/custom-depart.js'

export default {
  data () {
    return {
      homeComponent: null, // 首页组件
      currentUser: storage.get(APP_USER), // 登录人信息
      currentDept: storage.get(APP_DEPT) // 登录人部门
    }
  },
  created () {
    console.log('currentDept', this.currentDept)
    this.toHome(this.currentDept.sectionid)
  },
  methods: {
    // 根据登录人单位加载对应的首页组件
    toHome (departid) {
      if (ADMREVIEW_DEPART.includes(departid)) {
        // 行政复议首页
        this.homeComponent = () => import('@/views/accept/AcceptHome.vue')
      } else if (CORRECTION_DEPART.includes(departid)) {
        // 社区矫正首页
        this.homeComponent = () => import('@/views/correction/CorrectionHome.vue')
      } else {
        this.homeComponent = () => import('@/views/accept/AcceptHome.vue')
      }
    }
  }
}
</script>
